NB

  • custom.css should be in same folder as the notebook
  • then to display the slides

In [ ]:
jupyter nbconvert Welcome\ session\ Python\ for\ science\ BBRC.ipynb --to slides --post serve --template default_transition

Welcome session on Python for science

BarcelonaBeta Brain Research Center - April 4 2017

Check-list:

  • Python 2.7
  • IPython
  • Jupyter

Why Python?

  • for Science!
  • Easy, educational, many gateways to other languages and multiplatform.
  • Modular, modules, bricks, versatile (e.g. text processing, linear algebra, web development)
  • Human readable
  • GPL-compatible (open source) Free!
  • It is everywhere.

Great for working / teaching / sharing.

The scientist's needs:

  • get data
  • manipulate, process data
  • visualize results
  • communicate results

Slack

Ask your questions, learn, comment, share on everything.

Multi-platform, mobile apps, etc.

Visit http://fpmaragall.slack.com/

Communication based on real-time discussions in topic-oriented channels.

Join #python now !

Structure of the course :

  • April 3 1:15pm-2:45pm - Getting started in Python (~90 minutes)

  • April 10 2pm-3pm - Hands-on Numerical Python, Scientific Python and Visualization (~60 minutes)

  • April 24 2pm-3pm - Applications to Statistics, Machine Learning and Neuroimaging (~60 minutes)

Resources :

Bestiary :

  • Python: the language

  • Anaconda: a "distribution" (Python and friends)

  • IPython: Interactive Python (Python with some helpers)

  • IPython Notebook: Python in your browser (these slides are a IPython Notebook !)

The interactive workflow: IPython and a text editor

Hello world!

Open a terminal and start python


In [1]:
print('Hello world!')


Hello world!

Ipython

Now pen a terminal and start ipython


In [2]:
print('Hello world!')


Hello world!

Now what's the difference ?

Your first Python script

Now choose your favorite editor and create my_file.py.


In [6]:
s = 'Hello world !'
print(s)


Hello world !

IPython tips

Basic types

  • Integers

  • Floats

  • Complex

  • Booleans

Weakly typed

Arithmetical operations

Casting

Containers

  • Lists

  • Dictionaries

Strings

Dictionaries

Functions

Reusing code: import

Modules, packages

Inputs / outputs